package com.haha;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;

public class TestGatheringWrites {
    public static void main(String[] args) {
        ByteBuffer buffer = StandardCharsets.UTF_8.encode("HELLO");
        ByteBuffer buffer1 = StandardCharsets.UTF_8.encode("WORLD");
        ByteBuffer buffer2 = StandardCharsets.UTF_8.encode("你好");
        try (FileChannel channel=new RandomAccessFile("E:\\gulimail\\nettystudy\\word.txt","rw").getChannel()){
            channel.write(new ByteBuffer[]{buffer,buffer1,buffer2});
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
